package event;

import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;

class MyMouse implements MouseMotionListener{

	@Override
	public void mouseDragged(MouseEvent e) {		
		
	}

	@Override
	public void mouseMoved(MouseEvent e) {
		int x = e.getX();
		int y = e.getY();		
		
	}

}

class MyFrame extends JFrame implements MouseMotionListener{

	private JLabel lb = new JLabel("현재 좌표");
	private Canvas can = new Canvas();
	
	public MyFrame(){
		MyMouse m = new MyMouse();
		
		setLayout(new BorderLayout());
		add(lb,"North");
		add(can,"Center");
		can.setBackground(Color.YELLOW);
		
		
		setSize(500,500);
		setVisible(true);
	}

	@Override
	public void mouseDragged(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseMoved(MouseEvent e) {
		int x = getX();
		int y = getY();
		
		lb.setText("X : " + x + "Y : " + y);
		
	}
}



public class ActionEventEx4 extends Frame{
	
	public static void main(String[] args) {
		new MyFrame();

	}

}


